﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：QS_SF_YHPLDLHPHZ实体层次
//********************************************************************************//

#region Entity

using System;
using System.Data;
using Entity;
using Oracle.DataAccess.Client;
using Platform.Configuration;
using Platform.Data;

namespace Entity
{
    [Serializable]
    public class QS_SF_YHPLDLHPHZ
    {
        private decimal? m_dec_i_daozhangbs;

        private decimal? m_dec_i_jlzt;

        private decimal? m_dec_i_qitabs;

        private decimal? m_dec_i_tuipiaobs;

        private decimal? m_dec_i_yinhanglx;

        private decimal? m_dec_i_zongbis;

        private decimal? m_dec_i_zwym;

        private decimal m_dec_id;

        private decimal? m_dec_n_daozhangje;

        private decimal? m_dec_n_qitaje;

        private decimal? m_dec_n_tuipianje;

        private decimal? m_dec_n_zongjine;

        private DateTime? m_DT_d_daorurq;

        private DateTime? m_DT_d_riqi;

        private string m_str_s_bianhao;

        private string m_str_s_wenjianm;

        /// <summary>
        ///     主键
        /// </summary>
        public decimal ID
        {
            get { return m_dec_id; }
            set { m_dec_id = value; }
        }

        /// <summary>
        ///     编号
        /// </summary>
        public string S_BIANHAO
        {
            get { return m_str_s_bianhao; }
            set { m_str_s_bianhao = value; }
        }

        /// <summary>
        ///     账务年月
        /// </summary>
        public decimal? I_ZWYM
        {
            get { return m_dec_i_zwym; }
            set { m_dec_i_zwym = value; }
        }

        /// <summary>
        ///     文件名
        /// </summary>
        public string S_WENJIANM
        {
            get { return m_str_s_wenjianm; }
            set { m_str_s_wenjianm = value; }
        }

        /// <summary>
        ///     总金额
        /// </summary>
        public decimal? N_ZONGJINE
        {
            get { return m_dec_n_zongjine; }
            set { m_dec_n_zongjine = value; }
        }

        /// <summary>
        ///     总笔数
        /// </summary>
        public decimal? I_ZONGBIS
        {
            get { return m_dec_i_zongbis; }
            set { m_dec_i_zongbis = value; }
        }

        /// <summary>
        ///     日期
        /// </summary>
        public DateTime? D_RIQI
        {
            get { return m_DT_d_riqi; }
            set { m_DT_d_riqi = value; }
        }

        /// <summary>
        ///     导入日期
        /// </summary>
        public DateTime? D_DAORURQ
        {
            get { return m_DT_d_daorurq; }
            set { m_DT_d_daorurq = value; }
        }

        /// <summary>
        ///     到账金额
        /// </summary>
        public decimal? N_DAOZHANGJE
        {
            get { return m_dec_n_daozhangje; }
            set { m_dec_n_daozhangje = value; }
        }

        /// <summary>
        ///     到账笔数
        /// </summary>
        public decimal? I_DAOZHANGBS
        {
            get { return m_dec_i_daozhangbs; }
            set { m_dec_i_daozhangbs = value; }
        }

        /// <summary>
        ///     退票金额
        /// </summary>
        public decimal? N_TUIPIANJE
        {
            get { return m_dec_n_tuipianje; }
            set { m_dec_n_tuipianje = value; }
        }

        /// <summary>
        ///     退票笔数
        /// </summary>
        public decimal? I_TUIPIAOBS
        {
            get { return m_dec_i_tuipiaobs; }
            set { m_dec_i_tuipiaobs = value; }
        }

        /// <summary>
        ///     其他金额
        /// </summary>
        public decimal? N_QITAJE
        {
            get { return m_dec_n_qitaje; }
            set { m_dec_n_qitaje = value; }
        }

        /// <summary>
        ///     其他笔数
        /// </summary>
        public decimal? I_QITABS
        {
            get { return m_dec_i_qitabs; }
            set { m_dec_i_qitabs = value; }
        }

        /// <summary>
        ///     银行类型
        /// </summary>
        public decimal? I_YINHANGLX
        {
            get { return m_dec_i_yinhanglx; }
            set { m_dec_i_yinhanglx = value; }
        }

        /// <summary>
        ///     记录状态
        /// </summary>
        public decimal? I_JLZT
        {
            get { return m_dec_i_jlzt; }
            set { m_dec_i_jlzt = value; }
        }
    }
}

#endregion

#region EntityProcess

namespace BLL.Access
{
    //using System.Data.OracleClient;

    public class QS_SF_YHPLDLHPHZProcess
    {
        #region Field

        protected string conn;

        #endregion

        #region Construction

        public QS_SF_YHPLDLHPHZProcess()
        {
            conn = ConfigHelper.PlatformConnString;
        }

        #endregion

        #region public

        /// <summary>
        ///     根据QS_SF_YHPLDLHPHZ实体添加或者修改QS_SF_YHPLDLHPHZ信息
        /// </summary>
        public bool InsertOrUpdate(QS_SF_YHPLDLHPHZ QS_SF_YHPLDLHPHZ, OracleTransaction Transaction)
        {
            if (QS_SF_YHPLDLHPHZ.ID == 0)
                InsertQS_SF_YHPLDLHPHZ(QS_SF_YHPLDLHPHZ, Transaction);
            else
                UpdateQS_SF_YHPLDLHPHZ(QS_SF_YHPLDLHPHZ, Transaction);
            return QS_SF_YHPLDLHPHZ.ID == 0 ? false : true;
        }

        /// <summary>
        ///     根据QS_SF_YHPLDLHPHZ实体添加或修改QS_SF_YHPLDLHPHZ信息
        /// </summary>
        public bool InsertOrUpdate(QS_SF_YHPLDLHPHZ QS_SF_YHPLDLHPHZ)
        {
            return InsertOrUpdate(QS_SF_YHPLDLHPHZ, null);
        }


        /// <summary>
        ///     根据QS_SF_YHPLDLHPHZ主键删除QS_SF_YHPLDLHPHZ信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteQS_SF_YHPLDLHPHZ(decimal ID, OracleTransaction Transaction)
        {
            var spName = "CS_DelQS_SF_YHPLDLHPHZ";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        ///     根据QS_SF_YHPLDLHPHZ主键删除QS_SF_YHPLDLHPHZ信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteQS_SF_YHPLDLHPHZ(decimal ID)
        {
            return DeleteQS_SF_YHPLDLHPHZ(ID, null);
        }

        /// <summary>
        ///     根据条件删除QS_SF_YHPLDLHPHZ信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteQS_SF_YHPLDLHPHZsDynamic(string WhereClause, OracleTransaction Transaction)
        {
            var spName = "CS_DelQS_SF_YHPLDLHPHZsDyn";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WhereClause;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        ///     根据条件删除QS_SF_YHPLDLHPHZ信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteQS_SF_YHPLDLHPHZsDynamic(string WhereClause)
        {
            return DeleteQS_SF_YHPLDLHPHZsDynamic(WhereClause, null);
        }

        /// <summary>
        ///     根据QS_SF_YHPLDLHPHZ主键选择QS_SF_YHPLDLHPHZ信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>QS_SF_YHPLDLHPHZ信息</returns>
        public QS_SF_YHPLDLHPHZ SelectQS_SF_YHPLDLHPHZ(decimal ID, OracleTransaction Transaction)
        {
            var spName = "CS_SelQS_SF_YHPLDLHPHZ";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            OracleDataReader rd;
            if (Transaction == null)
                rd = OracleHelper.ExecuteReader(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                rd = OracleHelper.ExecuteReader(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (rd.Read())
            {
                var QS_SF_YHPLDLHPHZ = PopulateQS_SF_YHPLDLHPHZ(rd);
                rd.Close();
                return QS_SF_YHPLDLHPHZ;
            }
            return null;
        }

        /// <summary>
        ///     根据QS_SF_YHPLDLHPHZ主键选择QS_SF_YHPLDLHPHZ信息
        /// </summary>
        /// <returns>QS_SF_YHPLDLHPHZ信息</returns>
        public QS_SF_YHPLDLHPHZ SelectQS_SF_YHPLDLHPHZ(decimal ID)
        {
            return SelectQS_SF_YHPLDLHPHZ(ID, null);
        }

        /// <summary>
        ///     选择所有QS_SF_YHPLDLHPHZ信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>所有QS_SF_YHPLDLHPHZ信息</returns>
        public DataTable SelectQS_SF_YHPLDLHPHZsAll(OracleTransaction Transaction)
        {
            var spName = "CS_SelQS_SF_YHPLDLHPHZsAll";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            return null;
        }

        /// <summary>
        ///     选择所有QS_SF_YHPLDLHPHZ信息
        /// </summary>
        /// <returns>所有QS_SF_YHPLDLHPHZ信息</returns>
        public DataTable SelectQS_SF_YHPLDLHPHZsAll()
        {
            return SelectQS_SF_YHPLDLHPHZsAll(null);
        }

        /// <summary>
        ///     根据条件选择QS_SF_YHPLDLHPHZ信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>QS_SF_YHPLDLHPHZ信息</returns>
        public DataTable SelectQS_SF_YHPLDLHPHZsDynamic(string WhereClause, string OrderByExpression,
            OracleTransaction Transaction)
        {
            var spName = "CS_SelQS_SF_YHPLDLHPHZsDyn";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            return null;
        }


        /// <summary>
        ///     根据条件选择QS_SF_YHPLDLHPHZ信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <returns>QS_SF_YHPLDLHPHZ信息</returns>
        public DataTable SelectQS_SF_YHPLDLHPHZsDynamic(string WhereClause, string OrderByExpression)
        {
            return SelectQS_SF_YHPLDLHPHZsDynamic(WhereClause, OrderByExpression, null);
        }


        /// <summary>
        ///     根据条件选择QS_SF_YHPLDLHPHZ信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>QS_SF_YHPLDLHPHZ信息</returns>
        public DataTable SelectQS_SF_YHPLDLHPHZsDynamic(string WhereClause, string OrderByExpression, int PageIndex,
            int PageSize, OracleTransaction Transaction)
        {
            var spName = "CS_SelQS_SF_YHPLDLHPHZsDynPaged";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            storedParams[2].Value = PageIndex;
            storedParams[3].Value = PageSize;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            return null;
        }


        /// <summary>
        ///     根据条件选择QS_SF_YHPLDLHPHZ信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <returns>QS_SF_YHPLDLHPHZ信息</returns>
        public DataTable SelectQS_SF_YHPLDLHPHZsDynamic(string WhereClause, string OrderByExpression, int PageIndex,
            int PageSize)
        {
            return SelectQS_SF_YHPLDLHPHZsDynamic(WhereClause, OrderByExpression, PageIndex, PageSize, null);
        }

        /// <summary>
        ///     根据条件更新QS_SF_YHPLDLHPHZ字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateQS_SF_YHPLDLHPHZsDynamic(string UpdateValue, string WhereClause, OracleTransaction Transaction)
        {
            var result = 0;
            if (UpdateValue == "" || WhereClause == "")
                return 0;
            var spName = "CS_UpdQS_SF_YHPLDLHPHZDyn";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            storedParams[0].Value = UpdateValue;
            storedParams[1].Value = WhereClause;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            result = Convert.ToInt32(storedParams[2].Value);
            return result;
        }

        /// <summary>
        ///     根据条件更新QS_SF_YHPLDLHPHZ字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateQS_SF_YHPLDLHPHZsDynamic(string UpdateValue, string WhereClause)
        {
            return UpdateQS_SF_YHPLDLHPHZsDynamic(UpdateValue, WhereClause, null);
        }

        #endregion

        #region Private

        private int InsertQS_SF_YHPLDLHPHZ(QS_SF_YHPLDLHPHZ QS_SF_YHPLDLHPHZ, OracleTransaction Transaction)
        {
            var spName = "CS_InsQS_SF_YHPLDLHPHZ";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = QS_SF_YHPLDLHPHZ.S_BIANHAO;
            storedParams[1].Value = QS_SF_YHPLDLHPHZ.I_ZWYM;
            storedParams[2].Value = QS_SF_YHPLDLHPHZ.S_WENJIANM;
            storedParams[3].Value = QS_SF_YHPLDLHPHZ.N_ZONGJINE;
            storedParams[4].Value = QS_SF_YHPLDLHPHZ.I_ZONGBIS;
            storedParams[5].Value = QS_SF_YHPLDLHPHZ.D_RIQI;
            storedParams[6].Value = QS_SF_YHPLDLHPHZ.D_DAORURQ;
            storedParams[7].Value = QS_SF_YHPLDLHPHZ.N_DAOZHANGJE;
            storedParams[8].Value = QS_SF_YHPLDLHPHZ.I_DAOZHANGBS;
            storedParams[9].Value = QS_SF_YHPLDLHPHZ.N_TUIPIANJE;
            storedParams[10].Value = QS_SF_YHPLDLHPHZ.I_TUIPIAOBS;
            storedParams[11].Value = QS_SF_YHPLDLHPHZ.N_QITAJE;
            storedParams[12].Value = QS_SF_YHPLDLHPHZ.I_QITABS;
            storedParams[13].Value = QS_SF_YHPLDLHPHZ.I_YINHANGLX;
            storedParams[14].Value = QS_SF_YHPLDLHPHZ.I_JLZT;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            QS_SF_YHPLDLHPHZ.ID = Convert.ToInt32(storedParams[15].Value);
            return result;
        }

        private bool UpdateQS_SF_YHPLDLHPHZ(QS_SF_YHPLDLHPHZ QS_SF_YHPLDLHPHZ, OracleTransaction Transaction)
        {
            var spName = "CS_UpdQS_SF_YHPLDLHPHZ";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = QS_SF_YHPLDLHPHZ.S_BIANHAO;
            storedParams[1].Value = QS_SF_YHPLDLHPHZ.I_ZWYM;
            storedParams[2].Value = QS_SF_YHPLDLHPHZ.S_WENJIANM;
            storedParams[3].Value = QS_SF_YHPLDLHPHZ.N_ZONGJINE;
            storedParams[4].Value = QS_SF_YHPLDLHPHZ.I_ZONGBIS;
            storedParams[5].Value = QS_SF_YHPLDLHPHZ.D_RIQI;
            storedParams[6].Value = QS_SF_YHPLDLHPHZ.D_DAORURQ;
            storedParams[7].Value = QS_SF_YHPLDLHPHZ.N_DAOZHANGJE;
            storedParams[8].Value = QS_SF_YHPLDLHPHZ.I_DAOZHANGBS;
            storedParams[9].Value = QS_SF_YHPLDLHPHZ.N_TUIPIANJE;
            storedParams[10].Value = QS_SF_YHPLDLHPHZ.I_TUIPIAOBS;
            storedParams[11].Value = QS_SF_YHPLDLHPHZ.N_QITAJE;
            storedParams[12].Value = QS_SF_YHPLDLHPHZ.I_QITABS;
            storedParams[13].Value = QS_SF_YHPLDLHPHZ.I_YINHANGLX;
            storedParams[14].Value = QS_SF_YHPLDLHPHZ.I_JLZT;
            storedParams[15].Value = QS_SF_YHPLDLHPHZ.ID;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }


        private QS_SF_YHPLDLHPHZ PopulateQS_SF_YHPLDLHPHZ(IDataReader dr)
        {
            var QS_SF_YHPLDLHPHZ = new QS_SF_YHPLDLHPHZ();
            QS_SF_YHPLDLHPHZ.ID = dr["ID"] == DBNull.Value ? 0 : (decimal) dr["ID"];
            QS_SF_YHPLDLHPHZ.S_BIANHAO = dr["S_BIANHAO"] == DBNull.Value ? null : (string) dr["S_BIANHAO"];
            QS_SF_YHPLDLHPHZ.I_ZWYM = dr["I_ZWYM"] == DBNull.Value ? null : (decimal?) dr["I_ZWYM"];
            QS_SF_YHPLDLHPHZ.S_WENJIANM = dr["S_WENJIANM"] == DBNull.Value ? null : (string) dr["S_WENJIANM"];
            QS_SF_YHPLDLHPHZ.N_ZONGJINE = dr["N_ZONGJINE"] == DBNull.Value ? null : (decimal?) dr["N_ZONGJINE"];
            QS_SF_YHPLDLHPHZ.I_ZONGBIS = dr["I_ZONGBIS"] == DBNull.Value ? null : (decimal?) dr["I_ZONGBIS"];
            QS_SF_YHPLDLHPHZ.D_RIQI = dr["D_RIQI"] == DBNull.Value ? null : (DateTime?) dr["D_RIQI"];
            QS_SF_YHPLDLHPHZ.D_DAORURQ = dr["D_DAORURQ"] == DBNull.Value ? null : (DateTime?) dr["D_DAORURQ"];
            QS_SF_YHPLDLHPHZ.N_DAOZHANGJE = dr["N_DAOZHANGJE"] == DBNull.Value ? null : (decimal?) dr["N_DAOZHANGJE"];
            QS_SF_YHPLDLHPHZ.I_DAOZHANGBS = dr["I_DAOZHANGBS"] == DBNull.Value ? null : (decimal?) dr["I_DAOZHANGBS"];
            QS_SF_YHPLDLHPHZ.N_TUIPIANJE = dr["N_TUIPIANJE"] == DBNull.Value ? null : (decimal?) dr["N_TUIPIANJE"];
            QS_SF_YHPLDLHPHZ.I_TUIPIAOBS = dr["I_TUIPIAOBS"] == DBNull.Value ? null : (decimal?) dr["I_TUIPIAOBS"];
            QS_SF_YHPLDLHPHZ.N_QITAJE = dr["N_QITAJE"] == DBNull.Value ? null : (decimal?) dr["N_QITAJE"];
            QS_SF_YHPLDLHPHZ.I_QITABS = dr["I_QITABS"] == DBNull.Value ? null : (decimal?) dr["I_QITABS"];
            QS_SF_YHPLDLHPHZ.I_YINHANGLX = dr["I_YINHANGLX"] == DBNull.Value ? null : (decimal?) dr["I_YINHANGLX"];
            QS_SF_YHPLDLHPHZ.I_JLZT = dr["I_JLZT"] == DBNull.Value ? null : (decimal?) dr["I_JLZT"];
            return QS_SF_YHPLDLHPHZ;
        }


        private void AddRowNumber(DataTable dt)
        {
            dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
            for (var i = 0; i < dt.Rows.Count; i++)
                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
        }

        #endregion
    }
}

#endregion